from uuid import uuid4

from app.dao.models.mysql_gen import UserFeedBack, cst_now
from app.dao.user_feedback_dao import UserFeedbackDao
from app.types.apiproto.user_feedback_proto import FeedbackCreate


class UserFeedbackService:

    @classmethod
    def submit_feedback(cls, feedback_data: FeedbackCreate) -> UserFeedBack:
        feedback = UserFeedBack(
            id=str(uuid4()),
            student_id=feedback_data.student_id,
            content=feedback_data.content,
            created_at=cst_now(),
            status=0,
        )
        return UserFeedbackDao.create_feedback(feedback)

    @classmethod
    def list_feedbacks(cls) -> list[UserFeedBack]:
        return UserFeedbackDao.get_all_feedbacks()

    @classmethod
    def update_status(cls, feedback_id: str, status: int) -> bool:
        return UserFeedbackDao.update_feedback_status(feedback_id, status)

    @classmethod
    def get_feedbacks_for_student(cls, student_id: str) -> list[UserFeedBack]:
        return UserFeedbackDao.get_feedbacks_by_student_id(student_id)
